/*
 * @(#)SatrunConfigBootstrapConfiguration.java 1.0 2019年10月29日上午11:11:53
 *
 * Saturn Framework Co.Limt
 * Copyright (c) 2012-2019 tanks, Inc. All rights reserved.
 */
package com.saturn.cloud.config;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.encrypt.TextEncryptor;

import com.saturn.cloud.config.client.SatrunPropertySourceLocator;

/**
 * <dl>
 *    <dt><b>Title:</b></dt>
 *    <dd>
 *    	none
 *    </dd>
 *    <dt><b>Description:</b></dt>
 *    <dd>
 *    	<p>none
 *    </dd>
 * </dl>
 *
 * @author tanks
 * @version 1.0, 2019年10月29日
 * @since saturn-config-spring-boot-starter
 * 
 */
@Configuration
@ConditionalOnProperty(name = "spring.cloud.saturn.config.enabled", matchIfMissing = true)
public class SatrunConfigBootstrapConfiguration {
	
	@Bean
	@ConditionalOnMissingBean
	public SatrunConfigProperties nacosConfigProperties() {
		return new SatrunConfigProperties();
	}
	
	@Bean
	public SatrunPropertySourceLocator nacosPropertySourceLocator(SatrunConfigProperties satrunConfigProperties) {
		return new SatrunPropertySourceLocator(satrunConfigProperties);
	}
	
	@Bean
	@ConditionalOnProperty("jasypt.encryptor.password")
	public TextEncryptor textEncryptor(StringEncryptor StringEncryptor) {
		return new JasyptTextEncryptor(StringEncryptor);
	}
	
}
